home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / dev / src / wangisrc.lha / wangi / z / wpad_library / test.c < prev    next >
C/C++ Source or Header  |  1995-08-28  |  2KB  |  125 lines

  1. #include <exec/types.h>
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/wpad.h>
  5. #include <pragmas/wpad_pragmas.h>
  6. #include <libraries/wpad.h>
  7. #include <utility/hooks.h>
  8. #include <proto/commodities.h>
  9.  
  10. extern struct Library *WPadBase = NULL;
  11. extern struct Library *CxBase = NULL;
  12.  
  13. struct NewBroker nb = 
  14. {
  15.     NB_VERSION,
  16.     "wpad.library example",
  17.     "example",
  18.     "example",
  19.     0,0,0,0,0
  20. };
  21.  
  22. struct Hook hook;
  23.  
  24. #define rEG(x) register __ ## x
  25.  
  26. ULONG __saveds __asm hookfunc( rEG(a0) struct Hook *hook,
  27.                                rEG(a2) struct WPOPHookMsg *hmsg,
  28.                                rEG(a1) struct PadItem *node )
  29. {
  30.     if( hmsg->hm_MethodID == WPOP_HOOK_EXEC )
  31.         Printf("HOOK => \"%s\"\n", node->pi_Name);
  32.     return( WPOP_HOOKRETURN_OK );
  33. }
  34.  
  35. void main( void )
  36. {
  37.     hook.h_Entry = hookfunc;
  38.     hook.h_SubEntry = NULL;
  39.     hook.h_Data = NULL;
  40.     
  41.     if( (WPadBase = OpenLibrary("wpad.library", 0)) &&
  42.         (CxBase = OpenLibrary("commodities.library", 0)) )
  43.     {
  44.         struct MsgPort *port;
  45.         if( port = CreateMsgPort() )
  46.         {
  47.             CxObj *broker;
  48.             if( broker = CxBroker(&nb, NULL) )
  49.             {
  50.                 struct PadItem node1 =
  51.                 {
  52.                     {
  53.                         NULL,
  54.                         NULL,
  55.                         0,
  56.                         0,
  57.                         "Node 1"
  58.                     },
  59.                     NULL,
  60.                     "control alt 4",
  61.                     NULL,
  62.                     NULL,
  63.                     NULL
  64.                 };
  65.                 struct PadItem node2 =
  66.                 {
  67.                     {
  68.                         NULL,
  69.                         NULL,
  70.                         0,
  71.                         0,
  72.                         "Node 2"
  73.                     },
  74.                     NULL,
  75.                     "control alt 2",
  76.                     NULL,
  77.                     NULL,
  78.                     NULL
  79.                 };
  80.                 struct List list;
  81.                 struct Pad *pad1;
  82.                 struct TextAttr font = 
  83.                 {
  84.                     "topaz.font",
  85.                     8,
  86.                     0,
  87.                     FPB_ROMFONT
  88.                 };
  89.                 
  90.                 ActivateCxObj(broker, 1L);
  91.                 
  92.                 NewList(&list);
  93.                 
  94.                 AddHead(&list, (struct Node *)&node1);
  95.                 AddHead(&list, (struct Node *)&node2);
  96.  
  97.             
  98.             
  99.         
  100.                 if( (pad1 = WP_OpenPad(WPOP_Items, &list,
  101.                                         WPOP_Font, &font,
  102.                                        WPOP_Broker, broker,
  103.                                        WPOP_HotKey, "control alt 3",
  104.                                        WPOP_ProcName, "WangiPad_TEST_Pad",
  105.                                        WPOP_StackSize, 2000,
  106.                                        WPOP_Priority, -1,
  107.                                        WPOP_Hook, &hook,
  108.                                        TAG_END)) )
  109.                 {
  110.                     Printf("Pads opened!\n");
  111.                     Wait(SIGBREAKF_CTRL_C);
  112.  
  113.                     WP_ClosePadA(pad1, NULL);
  114.                     Printf("Pad 1 closed!\n");
  115.                 } else
  116.                     Printf("Can't open pads!\n");
  117.                 DeleteCxObjAll(broker);
  118.             }
  119.             DeleteMsgPort(port);
  120.         }
  121.         CloseLibrary(CxBase);
  122.         CloseLibrary(WPadBase);
  123.         Printf("Library closed!\n");
  124.     }
  125. }